Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement PCZT support #440

Merged
merged 6 commits into from
Dec 11, 2024
Merged

Implement PCZT support #440

merged 6 commits into from
Dec 11, 2024

Conversation

str4d
Copy link
Contributor

@str4d str4d commented Nov 27, 2024

No description provided.

@str4d str4d marked this pull request as draft November 27, 2024 10:03
///
/// - This is chosen by the Constructor.
/// - This is required by the IO Finalizer, and is cleared by it once used.
/// - Signers MUST reject PCZTs that contain `dummy_sk` values.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • I both named this dummy_sk and added a "MUST reject" here because I do not want PCZTs to get serialized with non-dummy spending keys.
  • I stored the dummy note's sk instead of the smaller-scoped ask, because in Orchard we impose validity requirements at parse time of sk (specifically to ensure that a valid ivk is produced), and we already had APIs for handling that parsing here. If desired this can be scoped down to dummy_ask, but given that (again) this field is only for dummy notes, I think sk should be fine here.

pub fn parse(
actions: Vec<Action>,
flags: u8,
value_sum: (u64, bool),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I decided on this serialization format for ValueSum (rather than e.g. i128) because it has no edge cases; all values are valid.

nuttycom
nuttycom previously approved these changes Nov 27, 2024
Copy link
Contributor

@nuttycom nuttycom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK e7a2945 with minor questions / naming nits. Overall this looks excellent.

let (anchor, merkle_path) = {
let cmx: ExtractedNoteCommitment = note.commitment().into();
let leaf = MerkleHashOrchard::from_cmx(&cmx);
let mut tree = BridgeTree::<MerkleHashOrchard, u32, 32>::new(100);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: since BridgeTree is no longer being maintained, we should move away from using it.


/// Authorizing data for a bundle of actions that is just missing a binding signature.
#[derive(Debug)]
pub struct Unbound {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: this name isn't particularly intuitive to me, but I don't have a better suggestion; maybe BindingSigInputs or something?

Copy link
Contributor Author

@str4d str4d Nov 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name appears primarily in type signatures, i.e. Bundle<Unbound, ZatBalance>; I chose it to make sense there (same as Authorized / Unauthorized / EffectsOnly).

@str4d
Copy link
Contributor Author

str4d commented Dec 3, 2024

Force-pushed to address comments and add missing serialization APIs.

@str4d str4d marked this pull request as ready for review December 3, 2024 11:41
@str4d
Copy link
Contributor Author

str4d commented Dec 3, 2024

Force-pushed to address another comment I missed.

@str4d
Copy link
Contributor Author

str4d commented Dec 3, 2024

Force-pushed to address another comment I missed, and fix clippy lints.

/// - `ephemeral_key`
/// - `enc_ciphertext`
/// - `out_ciphertext`
pub(crate) encrypted_note: TransmittedNoteCiphertext,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is going to be transaction version-dependent, e.g. the length will change in NU6 due to ZIP 231 and also ZSAs. So do Output and TransmittedNoteCiphertext need to be version-dependent types, or is it sufficient for TransmittedNoteCiphertext to contain a vector that is dynamically of the correct length?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the parsed typed type, so it can be whatever we want. The PCZT encoding uses Vec<u8> for both ciphertexts in anticipation of NU7.

nuttycom
nuttycom previously approved these changes Dec 4, 2024
Copy link
Contributor

@nuttycom nuttycom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK cb404f8 with nonblocking question about how to handle TransmittedNoteCiphertext in the future.

Co-authored-by: Daira-Emma Hopwood <[email protected]>
Co-authored-by: Kris Nuttycombe <[email protected]>
nuttycom
nuttycom previously approved these changes Dec 4, 2024
Copy link
Contributor

@nuttycom nuttycom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

re-utACK d132b5b

daira
daira previously approved these changes Dec 11, 2024
Copy link
Contributor

@daira daira left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK

Copy link
Contributor

@daira daira left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doc-only self-utACK 5b6cc68

@daira daira merged commit 5c451be into main Dec 11, 2024
27 checks passed
@daira daira deleted the pczt branch December 11, 2024 21:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants